/**
 * 基础菜单 user管理
 */
<template>
  <div>
    <!-- 面包屑导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>普通员工管理</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 搜索筛选 -->
    <el-form :inline="true" :model="formInline" class="user-search">
      <el-form-item label="查询员工信息-回车执行">
        <el-input size="small" v-model="inputEmpId" placeholder="输入员工编号" @keyup.enter.native="getByEmpId"></el-input>
      </el-form-item>
      <el-form-item label="员工上班打卡-回车执行">
        <el-input size="small" v-model="clockInEmpId" placeholder="输入员工编号" @keyup.enter.native="clockIn"></el-input>
      </el-form-item>
      <el-form-item label="员工下班打卡-回车执行">
        <el-input size="small" v-model="clockOutEmpId" placeholder="输入员工编号" @keyup.enter.native="clockOut"></el-input>
      </el-form-item>
      </el-form>

    

    <!-- 显示查询得到员工数据 -->
    <el-table :data="tableData" height="250"
    border
    style="width: 100%">
    <el-table-column prop="emp_id" label="emp_id" width="180">
    </el-table-column>
    <el-table-column prop="name" label="name" width="180">
    </el-table-column>
    <el-table-column prop="department_id" label="department_id" width="180">
    </el-table-column>
    <el-table-column prop="job_id" label="job_id" width="180">
    </el-table-column>
    <el-table-column prop="basic_Salary" label="basic_Salary" width="180">
    </el-table-column>
    <el-table-column prop="arrival_time" label="arrival_time" width="180">
    </el-table-column>
    <el-table-column prop="departure_time" label="departure_time" width="180">
    </el-table-column>
    <el-table-column prop="rest_holiday" label="rest_holiday" width="180">
    </el-table-column>
    <el-table-column prop="monthly_salary" label="monthly_salary" width="180">
    </el-table-column>
  </el-table>
    
<!-- 记录查询员工打卡表 -->
<el-button type="primary" @click="dialogVisible = true">查询记录</el-button>
  <el-dialog :visible.sync="dialogVisible">
            <p>empId:{{selectRecord}}</p>
  <el-form @submit.native.prevent>
              <el-input v-model="selectRecord"
                placeholder="输入员工编号-回车执行"
                @keyup.enter.native="getRecordByEmpId">
              </el-input>
  </el-form>
  <el-table :data="recordTableData" height="250"
    border
    style="width: 100%">
    <el-table-column prop="emp_id" label="emp_id" width="180">
    </el-table-column>
    <el-table-column prop="name" label="name" width="180">
    </el-table-column>
    <el-table-column prop="department_id" label="department_id" width="180">
    </el-table-column>
    <el-table-column prop="job_id" label="job_id" width="180">
    </el-table-column>
    <!-- <el-table-column prop="basic_Salary" label="basic_Salary" width="180">
    </el-table-column> -->
    <el-table-column prop="arrival_time" label="arrival_time" width="300">
    </el-table-column>
    <el-table-column prop="departure_time" label="departure_time" width="300">
    </el-table-column>
    <el-table-column prop="status" label="status" width="180">
    </el-table-column>
    <!-- <el-table-column prop="date" label="date" width="180">
    </el-table-column> -->
  </el-table>
  </el-dialog>

<!-- 查询记录员工请假信息 -->
<el-button type="primary" @click="dialogVisible1 = true">查询请假</el-button>
  <el-dialog :visible.sync="dialogVisible1">
            <p>empId:{{selectManager}}</p>
  <el-form @submit.native.prevent>
              <el-input v-model="selectManager"
                placeholder="输入员工编号-回车执行"
                @keyup.enter.native="getManagerByEmpId">
              </el-input>
  </el-form>
  <el-table :data="managerTableData" height="250"
    border
    style="width: 100%">
    <el-table-column prop="id" label="id" width="180">
    </el-table-column>
    <el-table-column prop="emp_id" label="emp_id" width="180">
    </el-table-column>
    <el-table-column prop="name" label="name" width="180">
    </el-table-column>
    <el-table-column prop="department_id" label="department_id" width="180">
    </el-table-column>
    <el-table-column prop="job_id" label="job_id" width="180">
    </el-table-column>
    <el-table-column prop="reason" label="reason" width="180">
    </el-table-column>
    <el-table-column prop="status" label="status" width="180">
    </el-table-column>
    <el-table-column prop="start_date" label="start_date" width="180">
    </el-table-column>
    <el-table-column prop="end_date" label="end_date" width="180">
    </el-table-column>
    <el-table-column prop="apply_time" label="apply_time" width="180">
    </el-table-column>
    <el-table-column prop="deal_time" label="deal_time" width="180">
    </el-table-column>
  </el-table>
  </el-dialog>
  
  </div>
</template>


<script>
// import { clockInEmp,clockOutEmp } from '../../api/userMG'
import Pagination from '../../components/Pagination'
export default {
  data() {
    return {
      nshow: true, //switch开启
      fshow: false, //switch关闭
      loading: false, //是显示加载
      editFormVisible: false, //控制编辑页面显示与隐藏
      dialogVisible: false,
      dialogVisible1: false,

       title: '添加',
      inputEmpId: '',
      selectRecord: '',
      selectManager: '',
      //放入员工信息
      tableData: [],
      recordTableData: [],
      managerTableData: [],

      //输入的上下班打卡员工编号
      clockInEmpId: '',
      clockOutEmpId: '',
      editForm: {
        deptId: '',
        deptName: '',
        deptNo: '',
        token: localStorage.getItem('logintoken')
      },
      
      formInline: {
        page: 1,
        limit: 100,
        varLable: '',
        varName: '',
        token: localStorage.getItem('logintoken')
      },
      
    }
  },
  // 注册组件
  components: {
    Pagination
  },
  /**
   * 数据发生改变
   */

  /**
   * 创建完毕
   */
  created() {
    this.getdata(this.formInline)
  },

  /**
   * 里面的方法只有被调用才会执行
   */
  methods: {
    getByEmpId() {
      const self = this
      this.$axios.get('/common/getInfo?emp_id=' + this.inputEmpId).then((res) => {
        console.log(res)
        self.tableData.push(res.data)
      // eslint-disable-next-line handle-callback-err
      }).catch((error) => {
        alert('false2')
      })
    },

    clockIn() {
      const self = this
      this.$axios.post('/common/user_on_work?emp_id=' + this.clockInEmpId).then((res) => {
        console.log(res)
      })
    },

    clockOut() {
     const self = this
      this.$axios.post('/common/user_off_work?emp_id=' + this.clockOutEmpId).then((res) => {
        console.log(res)
      })
    },

    getRecordByEmpId() {
      // const self = this
      this.$axios.get('/common/queryRecord?emp_id=' + this.selectRecord).then((res) => {
        console.log(res)
        this.recordTableData = res.data
      // eslint-disable-next-line handle-callback-err
      }).catch((error) => {
        alert('false3')
      })
    },
    getManagerByEmpId() {
      this.$axios.get('/common/queryManagers?emp_id=' + this.selectManager).then((res) => {
        console.log(res)
        this.managerTableData = res.data
      // eslint-disable-next-line handle-callback-err
      }).catch((error) => {
        alert('false4')
      })
    },
    // 获取公司列表
    
    // 分页插件事件
    callFather(parm) {
      this.formInline.page = parm.currentPage
      this.formInline.limit = parm.pageSize
      this.getdata(this.formInline)
    },
   
  }
}
</script>

<style scoped>
.user-search {
  margin-top: 20px;
}
.userRole {
  width: 100%;
}
</style>

 
 